%%% FOR EXOGENOUS L 
clear all; addpath('auxiliar'); addpath('Simulated_Datasets');load ParticleSPDE_ENDO

% FOR ENDOGENOUS L
%load('ParticleSPDE_endoBG_234_centered.mat')
%% Income
addpath('auxiliar')
figure('name','timse series debt and reserves/Output')
plot(time,y_data,'Linewidth',2,'Color','k'); hold on;
plot(time,income_mDE,'o','Linewidth',2,'Color','r','LineStyle','--','MarkerSize',5); hold on
plot(time,income_m,'x','Linewidth',2,'Color','b','LineStyle',':','MarkerSize',5); hold on
 xlim([initialy endy]); %; xlabel('Year'); 
 ylabel('Value');
legend('Data','Baseline','Social planner','Location','northeast');legend boxoff;
%legend('hide')
set(gca, 'FontSize',15)
exportfig(gcf,'Plots\Fig4A_Income.eps','color','cmyk','resolution',1600)
%exportfig(gcf,'Plots\Fig12A_Income.eps','color','cmyk','resolution',1600)

%% Private Dedault
figure('name','timse series debt and reserves/Output')
plot(time,pi_data*100,'Linewidth',2,'Color','k'); hold on;
plot(time,nonperf_mDE*100,'o','Linewidth',2,'Color','r','LineStyle','--','MarkerSize',5); hold on
plot(time,nonperf_m*100,'x','Linewidth',2,'Color','b','LineStyle',':','MarkerSize',5); hold on
%set(Hlegend,'Interpreter','Latex'); xlabel('Year'); 
legend('Data','Baseline','Social planner','Location','northwest');
ylabel('Percent');
%legend('hide');
legend boxoff; xlim([initialy endy]);
set(gca, 'FontSize',15)
exportfig(gcf,'Plots\Fig4B_Nonperforming.eps','color','cmyk','resolution',1600)
%exportfig(gcf,'Plots\Fig12B_Nonperforming.eps','color','cmyk','resolution',1600)

%% Financial Shock
figure('name','timse series debt and reserves/Output')
plot(time,kappa_mDE,'o','Linewidth',2,'Color','r','LineStyle','--','MarkerSize',5); hold on
plot(time,kappa_m,'x','Linewidth',2,'Color','b','LineStyle',':','MarkerSize',5); hold on
 xlim([initialy endy]); %xlabel('Year');ylabel('Financial shock change');
legend('Baseline','Social planner','Location','northeast');legend boxoff;
ylabel('Value');
%legend('hide')
set(gca, 'FontSize',15)
exportfig(gcf,'Plots\Fig4C_Financial.eps','color','cmyk','resolution',1600)
%exportfig(gcf,'Plots\Fig12C_Financial.eps','color','cmyk','resolution',1600)
%% Public Debt
figure('name','timse series debt and reserves/Output')
plot(time,(BGnfa_data+initialBG)*100,'Linewidth',2,'Color','k'); hold on
plot(time,(PubDebt_mDE+initialBG)*100,'o','Linewidth',2,'Color','r','LineStyle','--','MarkerSize',5); hold on
plot(time,(PubDebt_m+initialBG)*100,'x','Linewidth',2,'Color','b','LineStyle',':','MarkerSize',5); hold on
 xlim([initialy endy]);%;xlabel('Year');ylabel('Share of output ');
legend('Data','Baseline','Social planner','Location','northwest');legend boxoff;
ylabel('Percent');
%legend('hide')
set(gca, 'FontSize',15)
exportfig(gcf,'Plots\Fig4D_Public.eps','color','cmyk','resolution',1600)
%exportfig(gcf,'Plots\Fig12D_Public.eps','color','cmyk','resolution',1600)

%% Private Debt
figure('name','timse series debt and reserves/Output')
plot(time,(nfa_data+initialBG)*100,'Linewidth',2,'Color','k'); hold on
plot(time,(PVDebt_mDE+initialBG)*100,'o','Linewidth',2,'Color','r','LineStyle','--','MarkerSize',5); hold on
plot(time,(PVDebt_m+initialBG)*100,'x','Linewidth',2,'Color','b','LineStyle',':','MarkerSize',5); hold on
  xlim([initialy endy]); %xlabel('Year');ylabel('Share of output');
legend('Data','Baseline','Social planner','Location','northeast');legend boxoff;
ylabel('Percent');
%legend('hide')
set(gca, 'FontSize',15)
exportfig(gcf,'Plots\Fig4E_Private.eps','color','cmyk','resolution',1600)
%exportfig(gcf,'Plots\Fig12E_Private.eps','color','cmyk','resolution',1600)
%Excess_pvd=PVDebt_mDE'./nfa_data-1;
%% Spread
figure('name','timse series debt and reserves/Output')
 plot(time,spread_input*100,'Linewidth',2,'Color','k'); hold on;
 plot(time,spread_mDE*100,'o','Linewidth',2,'Color','r','LineStyle','--','MarkerSize',5); hold on
 plot(time,spread_m*100,'x','Linewidth',2,'Color','b','LineStyle',':','MarkerSize',5); hold on
  xlim([initialy endy]); %xlabel('Year');  ylabel('Basis points');
legend('Data','Baseline','Social planner','Location','northwest');legend boxoff;
ylabel('Percent');
%legend('hide')
set(gca, 'FontSize',15)
exportfig(gcf,'Plots\Fig4F_Spread.eps','color','cmyk','resolution',1600)
%exportfig(gcf,'Plots\Fig12F_Spread.eps','color','cmyk','resolution',1600)






%%
tauS=mean(tauSIM,1);
figure
plot(time,tauS(1,:)*100,'x','Linewidth',2,'Color',[.9 .2 0],'LineStyle','-.','MarkerSize',5); hold on
    xlim([initialy endy]); %ylabel('Percent');xlabel('time');
    ylabel('Percent');
legend('Tax rate on private borrowing','Location','northwest');legend boxoff;
set(gca, 'FontSize',15)
exportfig(gcf,'Plots\Fig4G_Tax.eps','color','cmyk','resolution',1600)
%exportfig(gcf,'Plots\Fig12G_Tax.eps','color','cmyk','resolution',1600)

xlim([initialy endy])

